<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi as UserApi;

/**
 * 后台首页控制器
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
class IndexController extends AdminController {

    static protected $allow = array( 'verify');

    /**
     * 后台首页
     * @author 麦当苗儿 <zuojiazi@vip.qq.com>
     */
    public function index(){
        if(UID){
           // $this->visite();
			$this->display();
        } else {
            $this->redirect('Public/login');
        }
    }

    public function visite() {
        if (!IS_ROOT) {
             $map['admin_id'] = UID;
        }  
           
        $t1 = date("Y-m-d", strtotime("-5 day"));
        $t2 = date('Y-m-d', strtotime("+5 day"));

        $map['_string']="FROM_UNIXTIME(`visit_next_time`,'%Y-%m-%d') >= '{$t1}' AND FROM_UNIXTIME(`visit_next_time`,'%Y-%m-%d') <= '{$t2}' ";

        $list   = $this->lists('StudenVisit',$map,"visit_next_time desc");
 
        foreach ($list as $key => &$value) {
                $s_id = $value['studen_id'];
                $fullNameRow = getrow("SELECT `fullname` FROM `ot_studen` WHERE ( id='{$s_id}' ) LIMIT 1 ");
                
                $value['sName'] =  $fullNameRow['fullname'] ;   
         }   
  


        $this->assign('_list', $list);
        $_cn = $this->fetch();

        die ($_cn?$_cn:false);

    }

}
